package fr.umlv.jee.jawp.persistence.object;

import java.io.Serializable;

public class Product implements Serializable, Content {

  /**
   * 
   */
  // members
  private static final long serialVersionUID = 1L;
  private String ASIN;
  private String name;
  private int categoryId = -1;
  private int quantity = 0;
  private int limit;
  private String responsible;

  // constructors
  public Product() {
    super();
  }

  // getters
  public String getASIN() {
    return ASIN;
  }

  public String getName() {
    return name;
  }

  public int getcategoryId() {
    return categoryId;
  }

  public int getQuantity() {
    return quantity;
  }

  public int getLimit() {
    return limit;
  }

  public String getResponsible() {
    return responsible;
  }

  // setters
  public void setCategoryId(int categoryId) {
    this.categoryId = categoryId;
  }

  public void setResponsible(String responsible) {
    this.responsible = responsible;
  }
  
  public void setASIN(String ASIN) {
    this.ASIN = ASIN;
  }

  public void setName(String newName) {
    this.name = newName;
  }

  public void setQuantity(int quantity) {
    this.quantity = quantity;
  }

  public void incQuantity(int quantity) {
    this.quantity += quantity;
  }

  public void incQuantity() {
    this.quantity++;
  }

  public void setLimit(String responsible) {
    this.responsible = responsible;
  }

  public void setLimit(int limit) {
    this.limit = limit;
  }

  // generic methods
  @Override
  public String toString() {
    return "Product named " + name + " (ASIN = " + ASIN + ")";
  }

  @Override
  public boolean equals(Object obj) {
    if ((obj instanceof Product) && (this.ASIN == ((Product) obj).ASIN))
      return true;
    return false;
  }
}
